﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using T_Material.Domain;
using T_Material.Infrastructure.Interface;
using T_Material.Read.API.Application.Commands.PurchaseCommand;

namespace T_Material.Read.API.Application.CommandHandlers.PurchaseHandler
{
    public class PurchaseInfoCommandHandler : IRequestHandler<PurchaseInfoCommand, Purchase>
    {
        private readonly IPurchaseRepository purchaseRepository;

        public PurchaseInfoCommandHandler(IPurchaseRepository purchaseRepository)
        {
            this.purchaseRepository = purchaseRepository;
        }

        public async Task<Purchase> Handle(PurchaseInfoCommand request, CancellationToken cancellationToken)
        {
            var info =await purchaseRepository.Get(request.Id);
            return info;
        }
    }
}
